import { createRouter ,createWebHashHistory } from 'vue-router'
import Layout from '../layout/index.vue'
import ProductSettingView from '../views/product/settingView.vue'
export const constantRoutes = [
  {
    path:'/',
    component: Layout,
    redirect:'/index',
    children:[
      
      {
        path:'index',
        component:import('../views/index/index.vue'),
        name:'index',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      },
    ]
  },
  {
    path:'/login',
    component:import('../views/index/login.vue'),
    name:'login',
    hidden:true,
  },
  {
    path:'/product',
    component: Layout,
    meta:{
      title:'商品管理',
      icon:'component'
    },
    redirect:'/product/list',
    children:[
      {
        path:'list',
        component:import('../views/product/list.vue'),
        name:'productList',
        meta:{
          title:'商品列表',
        }
      },
      {
        path:'addGoods',
        component:import('../views/product/addGoods.vue'),
        name:'addGoods',
        hidden:true,
        meta:{
          title:'添加商品',
        }
      },
      {
        path:'setting',
        component:ProductSettingView,
        redirect:'/product/setting/index',
        meta:{
          title:'商品设置',
        },
        children:[
          {
            path:'index',
            component:import('../views/product/settingIndex.vue'),
            hidden:true,
            meta:{
              title:'分类与型号',
              activeMenu:'/product/setting'
            }
          },
          {
            path:'category',
            component:import('../views/product/category.vue'),
            name:'productCategory',
            hidden:true,
            meta:{
              title:'新增分类',
              activeMenu:'/product/setting'
            }
          },
          {
            path:'spec',
            component:import('../views/product/spec.vue'),
            name:'productSpec',
            hidden:true,
            meta:{
              title:'新增型号',
              activeMenu:'/product/setting'
            }
          },
        ]
      },
      {
        path:'create',
        component:import('../views/product/create.vue'),
        name:'productCreate',
        hidden:true,
        meta:{
          title:'新增商品',
        }
      },
      
    ]
  },
  {
    path:'/setting',
    component:Layout,
    meta:{
      title:'店铺设置',
      icon:'lock'
    },
    redirect:'/setting/admin',
    children:[
      {
        path:'showSetting',
        component:import('../views/setting/showSetting.vue'),
        name:'showSetting',
        meta:{
          title:'显示设置',
        }
      },
      {
        path:'freight',
        component:import('../views/setting/freight.vue'),
        name:'freight',
        meta:{
          title:'运费模板',
        }
      },
      {
        path:'addFreight',
        component:import('../views/setting/addFreight.vue'),
        name:'addFreight',
        hidden:true,
        meta:{
          title:'添加运费模板',
        }
      },

      {
        path:'shipper',
        component:import('../views/shipper/index.vue'),
        name:'shipper',
        meta:{
          title:'快递设置',
        }
      },
      {
        path:'addShipper',
        component:import('../views/shipper/addShipper.vue'),
        name:'addShipper',
        hidden:true,
        meta:{
          title:'新增快递',
        }
      },
      {
        path:'shipperList',
        component:import('../views/shipper/shipperList.vue'),
        name:'shipperList',
        hidden:true,
        meta:{
          title:'快递列表',
        }
      },
      {
        path:'admin',
        component:import('../views/setting/admin.vue'),
        name:'settingAdmin',
        meta:{
          title:'管理员',
        }
      },
      {
        path:'editAdmin',
        component:import('../views/setting/editAdmin.vue'),
        name:'settingEditAdmin',
        hidden:true,
        meta:{
          title:'编辑管理员',
        }
      },
    ]
  },
  
  {
    path: '/404',
    component: () => import('../views/error-page/404.vue'),
    hidden: true
  }
]
export const asyncRoutes = [
]

const router = createRouter({
  history:createWebHashHistory(),
  routes:constantRoutes
})

export default router